<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>OGNL Expression</title>
</head>
<body>
<ul>
	<li>use property to get values from context and value stack<br>
		The domain model class must contain a default constructor that takes no arguments.<br>
		name: <s:property value="user.name" />
	<li>an object inside an object:<br>
		dog name: <s:property value="cat.friend.name" />
	<li>ordinary methods of an object<br>
		password length: <s:property value="user.password.length()"/><br>
		call talk(): <s:property value="cat.talk()"/>
	<li>method of the Action<br>
		call actionMethod: <s:property value="actionMethod()"/>
	<hr>
	<li>static methods/variables/constants<br>
		Have to include this constant configuration: <br>
		&lt;constant name="struts.ognl.allowStaticMethodAccess" value="true"&gt;&lt;/constant&gt;<br>
		To find out what constants are there, look for org.apache.struts2/default.properties in struts2-core.<br>
		call staticActionMethod: <s:property value="@ognl.OgnlAction@staticActionMethod()" />
	<li>use @@ to call methods in Math class<br>
		sin(1) = <s:property value="@@sin(1)" />
	<hr>
	<li>constructors<br>
		default user: <s:property value="new model.User()" /><br>
		another user: <s:property value="new model.User('weirdo','abc',8)" />
	<hr>
	<li>List<br>
		list (same for array): <s:property value="users"/><br>
		element in list: <s:property value="user[1]"/><br>
		set of property for all elements: <s:property value="users.{age}"/><br>
		set of property for a particular element: <s:property value="users.{age}[0]"/><br>
		    (or use this one: users[0].age)
	<li>Set<br>
		set: <s:property value="dogs"/><br>
	<li>Map<br>
		map: <s:property value="ownerships"/><br>
		map keys: <s:property value="ownerships.keys"/><br>
		map values: <s:property value="ownerships.values"/><br>
		map size: <s:property value="ownerships.size()"/>  (its ok to have "size()" or just "size")<br>
		<!--<s:property value="ownerships[new model.User('a', 'a', 0)]"/>-->
		find value corresponding to a key: <s:property value="ownerships[users[1]]"/> (or map[key] or map.key)
</ul>
<s:debug></s:debug> 
</body>
</html>